import axios from "@/pages/p-rs/services/request";
import urls from './config';
import { Parameters, DTO } from './type';

// 加油券基本信息
export function getCouponsBaseInfo(
  couponsId: string
) {
  return axios.post<CNPC.Res.page<DTO.CouponsBaseInfo>>(urls.couponsBaseInfo, { couponsId }, { loading: true })
}

// 获取加油券面值
export function getFaceValueList(
  couponsId: number | string
) {
  return axios.post<CNPC.Res.data<DTO.FaceValueList>>(urls.faceValueList, { couponsId }, { loading: true })
}

// 卡券可用油站列表
export async function usableStationNumber(couponsId: number | string) {
  const res = await axios.post<DTO.StationNumber>(urls.usableStationNumber, { couponsId }, { loading: true });
  return res.data;
}

// 获取未支付的订单
export function getUnPayOrder(
  // userId: string,
  productBaseInfoId: string
) {
  return axios.post<CNPC.Res.page<DTO.UnPayOrder>>(urls.getUnPayOrder, { productBaseInfoId }, {
    loading: true
  })
}

// 获取当前商品省钱卡基础信息
export function getEconomizeCardItemList(
  // userId: string,
  productBaseInfoId: string
) {
  return axios.post<CNPC.Res.page<DTO.EconomizeCardItemList>>(urls.getEconomizeCardItemList, { productBaseInfoId }, { loading: true })
}

// 获取用户当前商品可用省钱卡
export function getUserEconomizeCardList(
  // userId: string,
  productBaseInfoId: string
) {
  return axios.post<CNPC.Res.page<DTO.UserEconomizeCardList>>(urls.getUserEconomizeCardList, { productBaseInfoId }, { loading: true })
}

export function addOrder(
  productBaseInfoId: string,
  fuelCouponsList: Array<DTO.fuelCouponsList>,
  isEconomizeCard: number,
  amountsPayable: number,
  amountsPaid: number,
  payType: number,
  economizeCard?: DTO.economizeCardType,

) {
  // console.log(JSON.stringify({ productBaseInfoId, fuelCouponsList, isEconomizeCard, economizeCard, amountsPayable, amountsPaid, payType }));

  return axios.post<CNPC.Res.page<DTO.addOrder>>(urls.addOrder, { productBaseInfoId, fuelCouponsList, isEconomizeCard, amountsPayable, amountsPaid, payType, economizeCard }, { loading: true })
}

export function getAgreementInfo(
) {
  return axios.post<CNPC.Res.page<DTO.addOrder>>(urls.getAgreementInfo, {}, { loading: true })

}



